package cn.net.mysoft.account.api.entity;

import cn.net.mysoft.account.api.common.AlgInNeed;

public class AccountDetailEntity {
    long id;
    String userId;
    String opponent;
    String vno;
    int direction;
    int type;
    long amount;
    String createTime;
    String remark;
    long balanceBefore;
    long balanceAfter;
    String sign;

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getRemark() {
        return remark;
    }

    public void setId(long id) {
        this.id = id;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public long getBalanceBefore() {
        return balanceBefore;
    }

    public long getId() {
        return id;
    }

    public long getAmount() {
        return amount;
    }

    public long getBalanceAfter() {
        return balanceAfter;
    }

    public int getDirection() {
        return direction;
    }

    public String getOpponent() {
        return opponent;
    }

    public String getVno() {
        return vno;
    }

    public void setAmount(long amount) {
        this.amount = amount;
    }

    public void setDirection(int direction) {
        this.direction = direction;
    }

    public String getSign() {
        return sign;
    }

    public void setBalanceAfter(long balanceAfter) {
        this.balanceAfter = balanceAfter;
    }

    public void setBalanceBefore(long balanceBefore) {
        this.balanceBefore = balanceBefore;
    }

    public void setOpponent(String opponent) {
        this.opponent = opponent;
    }

    public void setVno(String vno) {
        this.vno = vno;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public void setSign(){
        setSign(AlgInNeed.shaEncode(this.toSignString()));
    }

    public boolean isValid(){
        return this.sign.equalsIgnoreCase(AlgInNeed.shaEncode(this.toSignString()));
    }

    @Override
    public String toString() {
        return "AccountDetailEntity{" +
                "id=" + id +
                ", userId='" + userId + '\'' +
                ", opponent='" + opponent + '\'' +
                ", vno='" + vno + '\'' +
                ", direction=" + direction +
                ", type=" + type +
                ", amount=" + amount +
                ", createTime='" + createTime + '\'' +
                ", remark='" + remark + '\'' +
                ", balanceBefore=" + balanceBefore +
                ", balanceAfter=" + balanceAfter +
                ", sign='" + sign + '\'' +
                '}';
    }

    public String toSignString() {
        return "AccountDetailEntity{" +
                "id=" + 0 +
                ", userId='" + userId + '\'' +
                ", opponent='" + opponent + '\'' +
                ", vno='" + vno + '\'' +
                ", direction=" + direction +
                ", type=" + type +
                ", amount=" + amount +
                ", createTime='" + createTime + '\'' +
                ", remark='" + remark + '\'' +
                ", balanceBefore=" + balanceBefore +
                ", balanceAfter=" + balanceAfter +
                ", sign='"  + '\'' +
                '}';
    }
}
